<template>
  <div id="home">
    <h3>{{msg}}</h3>
  </div>
</template>

<script>
import topMenu from '@/components/home/TopNavMenu'
import sideMenu from '@/components/home/SideNavMenu'
import HelloWorld from '@/components/HelloWorld'
import axios from 'axios'
export default {
  data () {
    const item = {
      date: '2016-05-02',
      name: '王小虎',
      address: '上海市普陀区金沙江路 1518 弄'
    }
    return {
      msg: '',
      height: window.innerHeight - 60 + 'px',
      tableData: Array(20).fill(item)
    }
  },
  components: {
    topMenu,
    sideMenu,
    HelloWorld
  },
  methods: {},
  created: function () {
    axios({
      method: 'post',
      url: '/api/home'
      // headers: {
      //   'Content-Type': 'application/x-www-form-urlencoded'
      // }
    })
      .then(result => {
        if (result.status === 200) {
          this.msg = result.data
        } else if (result.data.code === 401) {
          this.msg = result.data.message
        } else if (result.data.code === 403) {
          this.msg = result.data.message
        }
        console.log(result)
      })
      .catch(err => {
        console.log(err)
      })
  }
}
</script>

<style>
.el-header {
  background-color: #5082c4;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
</style>
